package com.qing.springcloud.utils;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.List;

/**
 * @author caozhipeng
 * @date 2025/7/12
 */
public class PageResult<T> {

   private long current;
   private long size;
   private long total;
   private List<T> records;
   private PageResult(){};
   public PageResult(long current, long size, long total, List<T> records) {
      this.current = current;
      this.size = size;
      this.total = total;
      this.records = records;
   }
    public static <T> PageResult<T> builder(Page<T> page) {
      return new PageResult<>(page.getCurrent(), page.getSize(), page.getTotal(), page.getRecords());
    }

    public static <T> PageResult<T> builder(Page<?> page,List<T> records) {
        return new PageResult<>(page.getCurrent(), page.getSize(), page.getTotal(),records);
    }


    public long getCurrent() {
        return current;
    }

    public void setCurrent(long current) {
        this.current = current;
    }

    public long getSize() {
        return size;
    }

    public void setSize(long size) {
        this.size = size;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public List<T> getRecords() {
        return records;
    }

    public void setRecords(List<T> records) {
        this.records = records;
    }
}
